/*
 * Copyright (c) 2018-2999 广州市蓝海创新科技有限公司 All rights reserved.
 *
 * https://www.mall4j.com/
 *
 * 未经允许，不可做商业用途！
 *
 * 版权所有，侵权必究！
 */

package com.yami.shop.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.yami.shop.bean.model.FaceBase;
import com.yami.shop.dao.FaceBaseMapper;
import com.yami.shop.service.FaceBaseService;
import com.yami.shop.common.util.PageParam;

import java.util.List;

/**
 * 人脸底图服务实现
 * @author AI Assistant
 */
@Service
public class FaceBaseServiceImpl extends ServiceImpl<FaceBaseMapper, FaceBase> implements FaceBaseService {

    @Autowired
    private FaceBaseMapper faceBaseMapper;

    @Override
    public List<FaceBase> listByFaceTypeAndStatus(Integer faceType, Integer status) {
        return this.list(new LambdaQueryWrapper<FaceBase>()
                .eq(faceType != null, FaceBase::getFaceType, faceType)
                .eq(status != null, FaceBase::getStatus, status));
    }

    @Override
    public List<FaceBase> listByStatus(Integer status) {
        return this.list(new LambdaQueryWrapper<FaceBase>()
                .eq(status != null, FaceBase::getStatus, status));
    }

    @Override
    public void saveFaceBase(FaceBase faceBase) {
        faceBaseMapper.insert(faceBase);
    }

    @Override
    public void updateFaceBase(FaceBase faceBase) {
        faceBaseMapper.updateById(faceBase);
    }

    @Override
    public void deleteFaceBase(Long faceBaseId) {
        faceBaseMapper.deleteById(faceBaseId);
    }

    @Override
    public IPage<FaceBase> pageByFaceTypeAndStatus(PageParam<FaceBase> page, Integer faceType, Integer status) {
        return faceBaseMapper.selectPage(page, new LambdaQueryWrapper<FaceBase>()
                .eq(faceType != null, FaceBase::getFaceType, faceType)
                .eq(status != null, FaceBase::getStatus, status));
    }
}